<template>
	<view class="kefang_out">
		<view class="top_box" style="text-align: center;">
			   <text>酒店房间列表</text>
					</view>

		<view class="table_box">
			<uni-table border stripe emptyText="暂无更多数据">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th width="40" align="center">房号</uni-th>
					<uni-th width="80" align="center">报修账号</uni-th>
					<uni-th width="80" align="left">报修物品</uni-th>
					<uni-th width="80" align="left">操作</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				
				<uni-tr v-for="(item, index) in list" :key="index">
					<uni-td>
					<u--image style="display: inline-block;position: relative;top: 5rpx;"
					:showLoading="true" src="../../static/fangjian.png" width="32rpx" height="32rpx" @click="click"></u--image>
					<text style="padding-left: 5rpx;">{{item.roomnum}}</text> 
					</uni-td>
					<uni-td>
					<text style="padding-left: 5rpx;">{{item.user_accout}}</text> 
					</uni-td>
					<uni-td style="color: red;">
				 <!-- {{item.baoxiuname}} -->
				 <text v-if="item.baoxiuname=='ketingdeng'?true:false">客厅灯</text>
					 <text v-if="item.baoxiuname=='dianshi'?true:false">电视</text>
					 <text v-if="item.baoxiuname=='chuangtoudeng'?true:false">床头灯</text>
					  <text v-if="item.baoxiuname=='xiyujiandeng'?true:false">洗浴间灯</text>
					   <text v-if="item.baoxiuname=='zoulangdeng'?true:false">走廊灯</text>
					   <text v-if="item.baoxiuname=='kongtiao'?true:false">空调</text>
					    <text v-if="item.baoxiuname=='bingxiang'?true:false">冰箱</text>
					</uni-td>
					
					
					<uni-td>
						
						<u-button @click="yuyue(item)" 
						style="width: 140rpx;margin: 10rpx 0;" size="mini" type="success" text="报修"></u-button>
						
						<!-- <u-button style="width: 120rpx; margin: 10rpx 0;"  size="mini" type="error" text="删除房间"></u-button> -->
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		
		
		<u-popup round="10" closeable mode="center" :show="poup_show" @close="close" >
			<view class="popup_box">
				<view class="tit">录入房间</view>
				<!-- account: '',
				day_nums: '',
				reasons: '' -->
				<view class="contnet_box">
					<u-form>
						<view class="item_input">
							<view class="label">房间号 &nbsp;&nbsp; &nbsp;</view>
							<view class="input"><u--input placeholder="请输入房间号" 
							border="surround" v-model="addForm.roomnum"></u--input></view>
						</view>
		<view class="item_input">
			<view class="label">房间价格</view>
			<view class="input"><u--input placeholder="请输入房间价格" 
			type="number"
			border="surround" v-model="addForm.room_price"></u--input></view>
		</view>
						
		
						<view class="add_btn" style="margin:40upx"><u-button
						 
						 type="success" style="width: 320upx;height: 70upx;" text="确定" @click="add"></u-button></view>
					</u-form>
				</view>
			</view>
		</u-popup>
		
	</view>
</template>

<script>
import { Request2 } from '@/until/api.js';
export default {
	data() {
		return {
			list: [],
			addForm: {
				roomnum: '',
				room_price: ''
			},
			poup_show: false,
		};
	},
	onShow() {
		this.getlist();
	},
	methods: {
		detail(item){
			uni.navigateTo({
				url:'/pages/kefang/detail?data='+JSON.stringify(item)
			})
		},
		// 预约
		async yuyue(item){
			console.log(item)
			var user_accout=uni.getStorageSync('account');
			var user_name=uni.getStorageSync('supername');
			var requsetdata={
				...item
				
			}
			var res = await Request2('/fangjian/ROOMrepair', 'post', requsetdata);
			// console.log(res,"res")
			if(res.data.code=="200"){
				
				this.$u.toast("修复成功!");
				this.getlist()
				// uni.redirectTo({
				// 	url: '/pages/kefang/MYyuyuefangjian'
				// });
			}else{
				this.$u.toast(res.data.msg);
				
			}
		},
	
		
		show_add() {
			this.poup_show = true;
		},
		close() {
			this.poup_show = false;
		},
		
		//获取列表
		async getlist() {
			var requsetdata = {
				pageNum: 1,
				pageSize: 999
			};
			var res = await Request2('/fangjian/ROOMreportList', 'post', requsetdata);
			this.list = res.data.data;
			// console.log(this.list, 'this.list');
		}
	}
};
</script>

<style lang="scss" scoped>
.top_box {
	margin: 20rpx;
	.addbtn {
		width: 150rpx;
		height: 80rpx;
	}
}
.popup_box {
	// background-color: #fff;
	width: 600upx;
	height: 400upx;

	overflow: hidden;

	box-sizing: border-box;
	// padding: 0 0upx;
	.contnet_box {
		padding: 20upx 20upx;
		.item_input {
			display: flex;
			width: 100%;
			// text-align: center;

			margin: 15upx 0;
			.label {
				line-height: 60upx;
			}
		}
	}

	.tit {
		text-align: center;
		margin-top: 40upx;
		font-size: 38upx;
		font-weight: 500;
	}
	.tips {
		margin: 60upx 0;
		color: #c2c2c2;
		font-size: 34upx;
		letter-spacing: 2upx;
	}
	.code {
		padding: 0;
		padding-left: 15upx;
	}
}

</style>

